<div id='ServerList' class="OneContainer">
	<div class="row">
		<div class="col-md-12 ">
			<div class="Panel PanelBlue">
				<div class="PanelTitle">服务器列表</div>
				<div class="PanelBody">
					<div class="row">
						<div class="col-sm-12 PanelItemF">
							<div class="PanelItem" v-on:click="newServerx()">
								<span class="glyphicon glyphicon-asterisk" aria-hidden="true"></span> 引导创建服务器
							</div>
							<div class="PanelItem" v-on:click="newServer()">
								<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 直接创建新的服务器
							</div>
							<div class="PanelItem" v-on:click="opt_all('start')">
								<span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> 启动所有服务端
							</div>
							<div class="PanelItem" v-on:click="opt_all('stop')">
								<span class="glyphicon glyphicon-remove-sign" aria-hidden="true"></span> 关闭所有服务端
							</div>
							<div class="PanelItem" v-on:click="newDocker()">
								<span class="glyphicon glyphicon-send" aria-hidden="true"></span> 创建 Docker 镜像
							</div>
						</div>
					</div>
					<div class=" ItemTableList"></div>
					<div class="PanelItem ItemTableList" v-for="item of items">
						<div class="row">
							<div class="col-md-7">
								<div class="PanelItemInfo">
									<h4 v-if="item.data.jarName == '' && !item.data.highCommande ">
										<span class="color-high-red">[未配置] </span>
										<s v-text="item.serverName"></s>
									</h4>
									<h4 v-if="item.data.highCommande">
										<span class="color-red">[自定义]</span>
										<span v-text="item.serverName"></span>
									</h4>
									<h4 v-if="item.data.jarName != '' && !item.data.highCommande">
										<span class="color-green">[普通端]</span>
										<span v-text="item.serverName"></span>
									</h4>
									状态:
									<span v-if="item.data.run" class="color-green"> 正在运行 </span>
									<span v-else="item.data.run" class="color-red"> 关闭 </span> | 创建时间:
									<span v-text="item.data.createDate"> </span> | 最后启动:
									<span v-text="item.data.lastDate"> </span> | 时间期限:
									<span v-text="item.data.timeLimitDate || '- - 永久 - -'"> </span> | 端:
									<span v-text="item.data.jarName || '未指定'"> </span>
								</div>
							</div>
							<div class="col-md-5 NextCol">
								<div class="PanelItemMuem">
									<button class="btn btn-primary" v-on:click="toTerminal(item.serverName);">
										终端
									</button>
									<button class="btn btn-success" v-on:click="toConsole(item.serverName);">
										控制
									</button>
									<button class="btn btn-info" v-on:click="onRedirect('./template/component/server.html','server/get',item.serverName);">
										参数
									</button>
									<span style="margin-left: 8px;"> | </span>
									<button class="btn btn-danger" v-on:click="toDeleteServer(item.serverName)">删除</button>

								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<script>
	MI.rListener('onload', function () {
		VIEW_MODEL.newVue('ServerList', {
			el: '#ServerList',
			methods: {
				toConsole: function (serverName) {
					MCSERVER.listenServername = serverName;
					RES.redirectPage('./template/component/console.html', 'server/console', serverName);
				},
				onRedirect: function (link, api, serverName) {
					RES.redirectPage(link, api, serverName);
				},
				newServer: function () {
					RES.redirectPage('./template/component/newserver.html', null, '');
				},
				newServerx: function () {
					RES.redirectPage('./template/component/newserverx.html', null, '');
				},
				opt_all: function (command) {
					if (confirm("您真的要执行这个影响所有服务器的操作吗？")) {
						WS.sendMsg('server/opt_all', command);
						setTimeout(function () {
							PAGE.refresh();
						}, 2000);
					}
				},
				toDeleteServer: function (serverName) {
					var result = confirm('是否删除 [' + serverName + '] 这个服务端？\n注意: 删除服务器并不会删除服务端文件,只会从控制面板删除！');
					if (!result) return;
					WS.sendMsg('server/delete', serverName);
					RES.redirectPage('./template/server.html', 'server/view');
				},
				toTerminal: function (serverName) {
					//设置全局监听变量
					MCSERVER.listenServername = serverName;
					RES.redirectPage('./template/component/terminal.html', null, '');
				},
				newDocker: function () {
					RES.redirectPage('./template/component/new_docker_image.html', null, '');
				}
			}
		});
	});

	MI.rListener('onend', function () {});
</script>